﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Imóveis - Inaldo Imóveis</title>

<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/style-imoveis.css" rel="stylesheet" type="text/css" />
<link href="css/style_radio_imoveis.css" rel="stylesheet" type="text/css" />
<link href="css/dd.css" rel="stylesheet" type="text/css" />
<link href="css/paginacao.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico"> <!--Icone para a aba do navegador-->

<script src="js/jquery-1-4-3-min.js" type="text/javascript"></script>
<script src="js/ie.js" type="text/javascript"></script>
<script src="js/cust_checkbox_plugin.js" type="text/javascript"></script>
<script src="js/jquery.dd.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function () {
	$('#menu ul li.imoveis').css("background", "url(images/index/detalhe-menu.png) no-repeat center left");
	
	$("input[type='radio']").custCheckBox();	
	
	try {
		$("#tipo-imovel").msDropDown({mainCSS:'dd2'});
		$("#bairro").msDropDown({mainCSS:'dd3'});
		
		$("#valor").msDropDown({mainCSS:'dd4'});	
	}catch(e) {
		alert("Error: "+e.message);
	}
	
	
	//Paginação
	function showLoader(){
		$('.search-background').fadeIn(200);
	}
	function hideLoader(){
		$('.search-background').fadeOut(200);
	};
	
	$("#paging_button li").click(function(){
		showLoader();
		
		$("#paging_button li").css({'background-color' : ''});
		$(this).css({'background-color' : '#D8543A'});

		$("#imovel").load("data_imovel.php?page=" + this.id, hideLoader);
		
		return false;
	});
	
	$("#1").css({'background-color' : '#D8543A'});
	showLoader();
	$("#imovel").load("data_imovel.php?page=1",  hideLoader);
		
});
</script>

</head>

<body>

<?php //Conexão com o banco de dados
include_once('admin/conexao/config.php');
$config = new Config();
$conexao = $config->conectar();

$per_page = 12;
$sql = "select DISTINCT(id_imovel) from imovel order by id_imovel";
$rsd = $conexao->prepare($sql);
$rsd->execute();
$count = $rsd->rowCount(PDO::FETCH_ASSOC);
$pages = ceil($count/$per_page);


//Tipo Imóvel e endereço
$queryTipoImovel = "select id_tipo, nome_tipo from tipo_imovel where ativado_tipo = 1 order by nome_tipo;";

$tipo_imovel = $conexao->prepare($queryTipoImovel);				

$tipo_imovel->execute();

$queryEndereco = "select DISTINCT(bairro) FROM endereco order by bairro;";
		
$endereco = $conexao->prepare($queryEndereco);						
		
$endereco->execute();


?>

<div id="geral">

  <div id="cabecalho">
	  <?php include("cabecalho.php"); ?>      
  </div> <!-- Fim div CABECALHO -->    
  
  <div id="conteudo">
   <form action="pesquisa-de-imoveis" method="post">
   
  		<div id="tipo-negocio">
        	<div id="tipo-negocio-todos">
            
           
            	<span class="group">	
                  <input type="radio" value="todos" name="tipo_negocio" checked="checked"/>Todos
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <input type="radio" value="comprar" name="tipo_negocio" class="radio_alugar" />Comprar
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <input type="radio" value="aluguel" name="tipo_negocio" class="radio_alugar" />Alugar
                </span>
            </div>
        </div><!--Fim div TIPO_NEGOCIO-->
        
        <div id="box-imoveis">
			<div id="box-imoveis-buscas">
            	
                <div id="box-imoveis-tipo-imovel">
                	<select name="tipo_imovel" id="tipo-imovel" style="width:242px;" tabindex="1">
              			    <option value="Tipo de imóvel">Tipo de imóvel</option> 
                          <?php
							  foreach($tipo_imovel as $lista) {	
						  ?>  
                                <option value="<?php echo $lista['id_tipo']; ?>"> <?php echo utf8_encode($lista['nome_tipo']); ?> </option>
                          <?php } ?>
              	</select> 
                </div><!--Fim div BOX-IMOVEIS-TIPO-IMOVEL-->
                
                <div id="box-imoveis-bairro">
                    <select name="bairro" id="bairro" style="width:242px;" tabindex="1">
                              <option value="Bairro">Bairro</option>
                                  
                                 <?php
								 	require_once("admin/sistema/remover_acentos.php");
                                    foreach($endereco as $listaEndereco) {	
                                ?>  
                                      <option value="<?php echo retira_acentos($listaEndereco['bairro']); ?>"> 
                                          <?php echo utf8_encode($listaEndereco['bairro']); ?> </option>
                                <?php } ?>
                    </select> 
                 </div><!--Fim div BOX-IMOVEIS-BAIRRO-->
                 
                 <div id="box-imoveis-valor">
                    <select name="valor" id="valor" style="width:242px;" tabindex="1">
                            <option value="">Valores R$</option>                
                    
                            <optgroup label="Venda">
                                <option value="1000 à 50000">1.000,00 à 50.000,00</option>
                                <option value="51000 à 100000">51.000,00 à 100.000,00</option>
                                <option value="101000 à 200000">101.000,00 à 200.000,00</option>
                                <option value="201000 à 400000">201.000,00 à 400.000,00</option>
                                <option value="401000 à 800000">401.000,00 à 800.000,00</option>                        
                                <option value="mais de 800000">mais de 800.000,00</option>					
                            </optgroup>
                            
                            <optgroup label="Aluguel">
                              <option value="200 à 500">200,00 à 500,00</option>
                              <option value="501 à 800">501,00 à 800,00</option>
                              <option value="801 à 1200">801,00 à 1.200,00</option>
                              <option value="1201 à 1700">1.201,00 à 1.700,00</option>
                              <option value="1701 à 2500">1.701,00 à 2.500,00</option>
                              <option value="2501 à 5000">2.501,00 à 5.000,00</option>
                              <option value="mais de 5000">mais de 5.001,00</option>					
                            </optgroup>				
                    </select> 
                 </div><!--Fim div BOX-IMOVEIS-VALOR-->
                        
            </div><!--Fim div BOX-IMOVEIS-BUSCAS-->           
            
            <input type="submit" name="pesquisar" value="" class="botao" />
            
   </form> <!--Form da pesquisa-->
        
        	<div id="box-imoveis-imoveis">
                        	
                <div class="search-background">
                    <label><img src="images/loader.gif" alt="" /></label>
                </div>
			                               
            	<div id="imovel"></div><!--Fim div IMOVEIS - aqui será carregando os imóveis-->
                
                
                <div id="paging_button" align="center">
                    <ul>
                    <?php
                    //Show page links
                    for($i=1; $i<=$pages; $i++)
                    {
                        echo '<li id="'.$i.'">'.$i.'</li>';
                    }?>
                    </ul>
                </div>   <!--Fim div PAGING_BUTTON-->             
                
            </div><!--Fim div BOX-IMOVEIS-IMOVEIS-->
        
        </div><!--Fim div BOX-IMOVEIS-->

  </div><!--Fim div CONTEUDO-->
</div><!-- Fim div GERAL -->

<div id="rodape">
	<div id="rodape-conteudo">
    	<?php include("rodape.php"); ?>
    </div><!--Fim div RODAPE-CONTEUDO-->
    
</div><!--Fim div RODAPE-->

</body>
</html>
